<!doctype html>
<html>
<head>
<script src="/blue/js/jquery.js"></script>
<link href="/blue/css/css.css" rel="stylesheet" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="format-detection" content="telephone=no" />
<meta charset="utf-8">
<title>无标题文档</title>
<style>
/*订单状态*/
.state_box{ height:43px; position:relative}
.state{ float:left; width:50%; line-height:43px; color:#65646b; font-size:14px; text-align:center}
.blue_block{ width:50%; position:absolute; left:0; bottom:0; height:2px; background-color:#01aff0;}
/*订单信息*/
.move_box{ width:100%; overflow:hidden}
.move{ width:500%; position:relative; clear:both; left:0}
.order_box{ float:left; width:20%;}
.order{ height:133px; position:relative; background-color:#fff; margin-bottom:14px;}
.order_title{ line-height:40px; color:#191919; padding-left:4%; font-size:16px;}
.order_text{ width:92%; margin-left:4%; position:relative; height:53px; padding-top:5px; box-sizing:border-box}
.order_text h1,.order_text h2{ line-height:20px; color:#191919; font-size:14px;}
.order_text p{ position:absolute;top:0;right:0; line-height:53px; color:#65646b; font-size:16px;}
.cancel{ width:65px; height:25px; border:1px solid #ccc; text-align:center; line-height:25px; border-radius:3px; float:right; margin-top:6px; margin-right:4%; color:#65646b;}
/*底部导航*/
.nav_box{ width:100%; height:51px; position:fixed; left:0; bottom:0; background-color:#fff;}
.nav_index,.nav_order,.nav_my{ width:33.3%; float:left;}
.nav_box img{ width:18px; height:auto; position:relative; left:50%; margin-left:-9px; margin-top:8px;}
.nav_box h1{ font-size:12px; text-align:center; color:#65646b; line-height:25px;}
.nav_box .current_nav{ color:#01aff0;}

</style>
</head>

<body style="background-color: #f9f9f9;">
<!--header顶部标题-->
<div class="header">我的订单
	<div class="header_left" onclick="window.history.go(-1)"><img src="/blue/images/return.png"></div>
</div>
<!--订单状态-->
<div class="state_box">
    <div class="state">进行中</div>
    <div class="state">已完成</div>
    <div class="blue_block"></div>
</div>
<!--订单信息-->
<div class="move_box">
<div class="move">

    <!--未付款-->
    <div class="order_box">
        <?php $ace=0;$a=0 ?>
        @foreach ($res as $v)
            @if($v->state == 0)
        <div id="order{{$ace}}" class="order" onclick="jiage(this.id)">
            <input type="hidden" name="id" value="{{ $v->id }}" class="id">
            <div class="border_top"></div>
            <div class="order_title">{{ $v->content }}</div>
            <div class="order_text">
                <div class="border_top"></div>
                <h1>{{ $v->publishedtime }}</h1>
                <h2>{{ $v->address_pid }}</h2>
                <p class="money">￥<span>{{ $v->money }}</span></p>
                <div class="border_bottom"></div>
            </div>
                <div class="cancel" style="border:#ff7f00 1px solid; color:#ff7f00;">未付款</div>
            <div class="border_bottom"></div>
        </div>
            @elseif($v->state == 1)
                <div id="order" class="order" onClick="document.location='order_underway?id={{$v->id}}';">
                    <input type="hidden" name="id" value="{{ $v->id }}" class="id" id="aa{{$a}}">
                    <div class="border_top"></div>
                    <div class="order_title">{{ $v->content }}</div>
                    <div class="order_text">
                        <div class="border_top"></div>
                        <h1>{{ $v->publishedtime }}</h1>
                        <h2>{{ $v->address_pid }}</h2>
                        <p>￥<span class="money">{{ $v->money }}</span></p>
                        <div class="border_bottom"></div>
                    </div>
                    <div class="cancel" id="{{$a}}" onclick="dd(this.id)">取消订单</div>
                    <div class="border_bottom"></div>
                </div>
            @endif
                <?php $ace++;$a++;?>
        @endforeach
    </div>

    <!--待评价-->
    <div class="order_box" style="display: none;">
        @foreach($res as $vs)
            @if($vs->state == 2)
            <div id="order" class="order" onClick="document.location='order?id={{$vs->id}}';">
                <input type="hidden" name="id" value="{{ $vs->id }}" class="id">
                <div class="border_top"></div>
                <div class="order_title">{{ $vs->content }}</div>
                <div class="order_text">
                    <div class="border_top"></div>
                    <h1>{{ $vs->publishedtime }}</h1>
                    <h2>{{ $vs->address_pid }}</h2>
                    <p>￥{{ $vs->money }}</p>
                    <div class="border_bottom"></div>
                </div>
                <div class="cancel" style="border:1px solid #01aff0; color:#01aff0;" onclick="document.location='evaluate';event.stopPropagation();">评价</div>
                <div class="border_bottom"></div>
            </div>
            @elseif($vs->state == 3)
                <div class="order">
                    <input type="hidden" name="id" value="{{ $vs->id }}" class="id">
                    <div class="border_top"></div>
                    <div class="order_title">{{ $vs->content }}</div>
                    <div class="order_text">
                        <div class="border_top"></div>
                        <h1>{{ $vs->publishedtime }}</h1>
                        <h2>{{ $vs->address_pid }}</h2>
                        <p>￥{{ $vs->money }}</p>
                        <div class="border_bottom"></div>
                    </div>
                <div class="cancel" style="border:none">已退款</div>
                <div class="border_bottom"></div>
            </div>
            @elseif($vs->state == 4)
                <div id="order" class="order" onClick="document.location='order?id={{$v->id}}}';">
                    <input type="hidden" name="id" value="{{ $vs->id }}" class="id">
                    <div class="border_top"></div>
                    <div class="order_title">{{ $vs->content }}</div>
                    <div class="order_text">
                        <div class="border_top"></div>
                        <h1>{{ $vs->publishedtime }}</h1>
                        <h2>{{ $vs->address_pid }}</h2>
                        <p>￥{{ $vs->money }}</p>
                        <div class="border_bottom"></div>
                    </div>
                <div class="cancel" style="border:none">已完成</div>
                <div class="border_bottom"></div>
            </div>
            @else
                <input type="hidden" />
            @endif
        @endforeach
    </div>
</div>
</div>
<!--底部导航-->
<div class="nav_box">
	<div class="border_top"></div>
	<div class="nav_index chenge" onclick="document.location='/';">
    	<img src="/blue/images/index_gray.png">
        <h1 style=" ">首页</h1>
    </div>
    <div class="nav_order chenge" onclick="document.location='myorder';" >
    	<img src="/blue/images/order_blue.png">
        <h1 style="color:#01AFF0">订单</h1>
    </div>
    <div class="nav_my chenge" onclick="document.location='index_center';" >
    	<img src="/blue/images/my_gray.png">
        <h1>我的</h1>
    </div>
</div>
<script>
$(".state:eq(0)").click(
	function(){
		$(".blue_block").animate({left:'0%'})
        $(".order_box").eq(0).css("display","block")
        $(".order_box").eq(1).css("display","none")
		}
)
$(".state:eq(1)").click(
	function(){
		$(".blue_block").animate({left:'50%'})
        $(".order_box").eq(0).css("display","none")
        $(".order_box").eq(1).css("display","block")
		}
)
function jiage(id){
    var name = $('#'+id).find('input').val();
    var a=$("#"+id).find('span').text();
    $.get("order",{"a":a,"id":name},function(res){
        alert("付款"+a);
        window.location.href='order?id='+name;
    });
};

function dd(id){
    var name = $("#aa"+id).val();
    var money=$("#aa"+id).siblings('.order_text').find("p").find('.money').text();
    $.get("order_out",{"name":name,"money":money},function(res){
        if(res == 1){
            alert("退款成功");
            window.location.href='myorder';
        }else{
            alert("退款失败");
            window.location.href='myorder';
        }
    });
    event.stopPropagation();
}
</script>
</body>
</html>

